<%@ page language="java"
	import="com.byxy.model.PayInfo, com.byxy.service.PayInfoServiceImpl, com.byxy.util.DateUtil"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'findById.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="BasicInfo/bootstrap.min.css" rel="stylesheet"
	type="text/css">
<script type="text/javascript">
	function CheckAll(elementsA, elementsB) {
		for (i = 0; i < elementsA.length; i++) {
			elementsA[i].checked = true;
		}
		if (elementsB.checked == false) {
			for (j = 0; j < elementsA.length; j++) {
				elementsA[j].checked = false;
			}
		}
	}
	//判断用户是否选择了要删除的记录，如果是，则提示“是否删除”；否则提示“请选择要删除的记录”
	function checkdel(delid, formname) {
		var flag = false;
		for (i = 0; i < delid.length; i++) {
			if (delid[i].checked) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			alert("请选择要删除的记录！");
			return false;
		} else {
			if (confirm("确定要删除吗？")) {
				formname.submit();
			}
		}
	}
	function chkads() {
		if (if_selectid.txtid.value == "") {
			alert("编号不能为空.");
			if_selectid.txtid.select();
			return false;
		}
		if (!IsNum(if_selectid.txtid.value)) {
			alert("请输入数字!")
			if_selectid.txtid.focus();
			return false;
		}
	}
	function IsNum(num) {
		var reNum = /^\d*$/;
		return (reNum.test(num));
	}
</script>
</head>

<body>
	<%
		int id = Integer.parseInt(request.getParameter("txtid"));
		PayInfoServiceImpl paySer = new PayInfoServiceImpl();
		PayInfo pay = paySer.findById(id);
	%>
	<form onSubmit="return chkads()" name="if_selectid"
		action="./PayInfoFindByIdServlet" method="get">

		<table class="table table-striped table-bordered table-condensed list">
			<tbody>
				<tr>
					<td>输入查询的编号：</td>
					<td><input type="text" name="txtid" /></td>&nbsp;&nbsp;&nbsp;&nbsp;
					<td><input class="btn btn-inverse" id="find" type="submit"
						value="查询" /></td>
				</tr>
			</tbody>
		</table>
	</form>

	<form action="./PayInfoDelServlet" method="post" name="frm">

		<table class="table table-striped table-bordered table-condensed list">
			<tr>
				<td>编号</td>
				<td>名称</td>
				<td>时间</td>
				<td>费用</td>
				<td>备注</td>
				<td>党员基本信息编号</td>
				<td>&nbsp;删除</td>
				<td align="center">操作</td>
			</tr>
			<tr class="demo">
				<td><%=pay.getId()%></td>
				<td><%=pay.getName()%></td>
				<td><%=DateUtil.utilDateTosqlDate(pay.getHours())%></td>
				<td><%=pay.getCost()%></td>
				<td><%=pay.getText()%></td>
				<td><%=pay.getBasicInfoId()%></td>
				<td><input name="delid" type="checkbox" class="noborder"
					value="<%=pay.getId()%>"></td>
				<td>
					<div class="button-group">
						<a class="button border-main"
							href="PayInfo/update.jsp?id=<%=pay.getId()%>"><span
							class="icon-edit"></span>修改</a> <a class="button border-main"
							href="PayInfo/detailed.jsp?id=<%=pay.getId()%>"><span
							class="icon-edit"></span>详细信息</a>
					</div>
				</td>
			</tr>
		</table>
		<footer> <input name="checkbox" type="checkbox"
			class="noborder" onClick="CheckAll(frm.delid,frm.checkbox)">
		[全选/反选] [ <a style="color:red;cursor:pointer;"
			onClick="checkdel(frm.delid,frm)">删除</a>] <a href="#" type=”button”
			name=”submit” onclick="javascript:history.back(-1);">返回上一页</a>
		<div id="ch" style="display: none">
			<input name="delid" type="checkbox" value="0">
		</div>
		<!--层ch用于放置隐藏的checkbox控件，因为当表单中只是一个checkbox控件时，应用javascript获得其length属性值为undefine-->
		</footer>
	</form>
</body>
</html>
